<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>avalon: E:/avalon/src/libavalon/netbus.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">avalon
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search',false);
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_f51b14f5b402f75e5fe3fdf41b0bea7b.html">libavalon</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="headertitle"><div class="title">netbus.h</div></div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="preprocessor">#ifndef NETBUS_H_</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="preprocessor">#define NETBUS_H_</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span> </div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span> </div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="keyword">class </span><a class="code hl_class" href="class_connect_pool.html">ConnectPool</a>;</div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="keyword">class </span><a class="code hl_class" href="class_provider.html">Provider</a>;</div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span><span class="keyword">class </span><a class="code hl_class" href="class_deliver.html">Deliver</a>;</div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span> </div>
<div class="foldopen" id="foldopen00021" data-start="{" data-end="};">
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"><a class="line" href="class_net_bus.html">   21</a></span><span class="keyword">class </span><a class="code hl_class" href="class_net_bus.html">NetBus</a></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span>{</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span>    <span class="keyword">static</span> <a class="code hl_class" href="class_net_bus.html">NetBus</a> *<a class="code hl_function" href="class_net_bus.html#a6730ed76cfcb88c0f8c5cb9026511edf">GetInstance</a>();</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span> </div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_net_bus.html#a916098b510591da35b396267c2c9c574">setHost</a>(<span class="keyword">const</span> std::string &amp;host = <span class="stringliteral">&quot;localhost&quot;</span>);</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span> </div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_net_bus.html#aece284aa9bad59e420d4d996054d5622">setPort</a>(uint port = 5672);</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_net_bus.html#aa397dad126a7ef720941ec74246a442d">setUsername</a>(<span class="keyword">const</span> std::string &amp;username = <span class="stringliteral">&quot;guest&quot;</span>);</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span> </div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_net_bus.html#ae1af01e75a40f6871e156528aebc035c">setPassword</a>(<span class="keyword">const</span> std::string &amp;password = <span class="stringliteral">&quot;guest&quot;</span>);</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span> </div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_net_bus.html#a2648948b3505f7ce758fd574730a0f82">setThreadNum</a>(<span class="keywordtype">int</span> thread_num = 4);</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span> </div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_net_bus.html#ad6e84fe0101615c5a277fd8dcec69d1b">start</a>();</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span> </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="class_net_bus.html#aa65e7a7f54e20e2fbab64c157157b19f">addProvider</a>(<a class="code hl_class" href="class_provider.html">Provider</a> *provider);</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span> </div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="class_net_bus.html#aa902c4be48109d816a0cf3aeb445119d">send</a>(<a class="code hl_class" href="class_deliver.html">Deliver</a> *deliver);</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span> </div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="class_net_bus.html#a922510e0f6fa52fe1d654780b840b966">sendAndReceived</a>(<a class="code hl_class" href="class_deliver.html">Deliver</a> *deliver);</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span> </div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span><span class="keyword">private</span>:</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno">   90</span>    <a class="code hl_class" href="class_net_bus.html">NetBus</a>();</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span> </div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span>    <a class="code hl_class" href="class_net_bus.html">~NetBus</a>();</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span> </div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span><span class="keyword">private</span>:</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>    std::string host_;     <span class="comment">// RabbitMQ主机信息</span></div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span>    uint port_;            <span class="comment">// RabbitMQ端口号</span></div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span>    std::string username_; <span class="comment">// RabbitMQ用户名</span></div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span>    std::string password_; <span class="comment">// RabbitMQ密码</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>    <span class="keywordtype">int</span> thread_num_;       <span class="comment">// NetBus使用的线程数量</span></div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span> </div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span>    <a class="code hl_class" href="class_connect_pool.html">ConnectPool</a> *connect_pool_;         <span class="comment">// 连接池指针，用于管理RabbitMQ连接</span></div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span>    std::vector&lt;Provider *&gt; providers_; <span class="comment">// Provider列表，每个Provider对应一个RabbitMQ的Queue</span></div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span>};</div>
</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span> </div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span><span class="preprocessor">#endif </span><span class="comment">// NETBUS_H_</span></div>
<div class="ttc" id="aclass_connect_pool_html"><div class="ttname"><a href="class_connect_pool.html">ConnectPool</a></div><div class="ttdoc">提供了连接池的功能，用于管理和异步化与消息代理的连接和通信。</div><div class="ttdef"><b>Definition</b> connect_pool.h:16</div></div>
<div class="ttc" id="aclass_deliver_html"><div class="ttname"><a href="class_deliver.html">Deliver</a></div><div class="ttdoc">类，用于处理消息的投递。</div><div class="ttdef"><b>Definition</b> deliver.h:40</div></div>
<div class="ttc" id="aclass_net_bus_html"><div class="ttname"><a href="class_net_bus.html">NetBus</a></div><div class="ttdoc">消息总线类</div><div class="ttdef"><b>Definition</b> netbus.h:22</div></div>
<div class="ttc" id="aclass_net_bus_html_a2648948b3505f7ce758fd574730a0f82"><div class="ttname"><a href="class_net_bus.html#a2648948b3505f7ce758fd574730a0f82">NetBus::setThreadNum</a></div><div class="ttdeci">void setThreadNum(int thread_num=4)</div><div class="ttdoc">设置NetBus使用的线程数量</div><div class="ttdef"><b>Definition</b> netbus.cpp:44</div></div>
<div class="ttc" id="aclass_net_bus_html_a6730ed76cfcb88c0f8c5cb9026511edf"><div class="ttname"><a href="class_net_bus.html#a6730ed76cfcb88c0f8c5cb9026511edf">NetBus::GetInstance</a></div><div class="ttdeci">static NetBus * GetInstance()</div><div class="ttdoc">获取NetBus的唯一实例</div><div class="ttdef"><b>Definition</b> netbus.cpp:18</div></div>
<div class="ttc" id="aclass_net_bus_html_a916098b510591da35b396267c2c9c574"><div class="ttname"><a href="class_net_bus.html#a916098b510591da35b396267c2c9c574">NetBus::setHost</a></div><div class="ttdeci">void setHost(const std::string &amp;host=&quot;localhost&quot;)</div><div class="ttdoc">设置RabbitMQ连接的主机信息</div><div class="ttdef"><b>Definition</b> netbus.cpp:24</div></div>
<div class="ttc" id="aclass_net_bus_html_a922510e0f6fa52fe1d654780b840b966"><div class="ttname"><a href="class_net_bus.html#a922510e0f6fa52fe1d654780b840b966">NetBus::sendAndReceived</a></div><div class="ttdeci">bool sendAndReceived(Deliver *deliver)</div><div class="ttdoc">发送消息并等待接收回复，会阻塞等待直到发送成功或超时，超时时返回false</div><div class="ttdef"><b>Definition</b> netbus.cpp:132</div></div>
<div class="ttc" id="aclass_net_bus_html_aa397dad126a7ef720941ec74246a442d"><div class="ttname"><a href="class_net_bus.html#aa397dad126a7ef720941ec74246a442d">NetBus::setUsername</a></div><div class="ttdeci">void setUsername(const std::string &amp;username=&quot;guest&quot;)</div><div class="ttdoc">设置RabbitMQ连接的用户名</div><div class="ttdef"><b>Definition</b> netbus.cpp:34</div></div>
<div class="ttc" id="aclass_net_bus_html_aa65e7a7f54e20e2fbab64c157157b19f"><div class="ttname"><a href="class_net_bus.html#aa65e7a7f54e20e2fbab64c157157b19f">NetBus::addProvider</a></div><div class="ttdeci">bool addProvider(Provider *provider)</div><div class="ttdoc">添加一个Provider，每个Provider对应一个RabbitMQ的Queue</div><div class="ttdef"><b>Definition</b> netbus.cpp:80</div></div>
<div class="ttc" id="aclass_net_bus_html_aa902c4be48109d816a0cf3aeb445119d"><div class="ttname"><a href="class_net_bus.html#aa902c4be48109d816a0cf3aeb445119d">NetBus::send</a></div><div class="ttdeci">bool send(Deliver *deliver)</div><div class="ttdoc">发送消息，会阻塞等待直到发送成功或超时，超时时返回false</div><div class="ttdef"><b>Definition</b> netbus.cpp:107</div></div>
<div class="ttc" id="aclass_net_bus_html_ad6e84fe0101615c5a277fd8dcec69d1b"><div class="ttname"><a href="class_net_bus.html#ad6e84fe0101615c5a277fd8dcec69d1b">NetBus::start</a></div><div class="ttdeci">void start()</div><div class="ttdoc">启动NetBus，初始化并开始工作</div><div class="ttdef"><b>Definition</b> netbus.cpp:56</div></div>
<div class="ttc" id="aclass_net_bus_html_ae1af01e75a40f6871e156528aebc035c"><div class="ttname"><a href="class_net_bus.html#ae1af01e75a40f6871e156528aebc035c">NetBus::setPassword</a></div><div class="ttdeci">void setPassword(const std::string &amp;password=&quot;guest&quot;)</div><div class="ttdoc">设置RabbitMQ连接的密码</div><div class="ttdef"><b>Definition</b> netbus.cpp:39</div></div>
<div class="ttc" id="aclass_net_bus_html_aece284aa9bad59e420d4d996054d5622"><div class="ttname"><a href="class_net_bus.html#aece284aa9bad59e420d4d996054d5622">NetBus::setPort</a></div><div class="ttdeci">void setPort(uint port=5672)</div><div class="ttdoc">设置RabbitMQ连接的端口号</div><div class="ttdef"><b>Definition</b> netbus.cpp:29</div></div>
<div class="ttc" id="aclass_provider_html"><div class="ttname"><a href="class_provider.html">Provider</a></div><div class="ttdoc">服务提供者基类</div><div class="ttdef"><b>Definition</b> provider.h:24</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
